﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Manage_Admin_edit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //SqlConnection strcon = Class1.DBconnection();
            SqlConnection strcon = Class1.DBconnection();
            strcon.Open();
            SqlDataAdapter sda = new SqlDataAdapter("select * from tb_Admin where id=1",strcon);
            DataSet ds = new DataSet();
            sda.Fill(ds, "tb_Admin");
            DataRowView rowview = ds.Tables["tb_Admin"].DefaultView[0];
            this.adminname.Text = rowview["username"].ToString();
            this.adminpwd.Text = rowview["userpwd"].ToString();
            strcon.Close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //SqlConnection strcon = Class1.DBconnection();
        SqlConnection strcon = Class1.DBconnection();
        strcon.Open();
        SqlCommand scd = new SqlCommand("update tb_Admin set username='"+this.adminname.Text.ToString()+"',userpwd='"+this.adminpwd.Text.ToString()+"' where id=1",strcon);
        scd.ExecuteNonQuery();
        strcon.Close();
        Response.Write("<script language=javascript>alert('修改成功');location='Admin_edit.aspx'</script>");
    }
}
